package com.demo.test.state.mode;

import com.demo.test.state.mode.iml.State;

public class CurrTime9 implements State {

    public void handle(WorkContext workContext){

        if(workContext.getCurrTime() == 9 ){
            this.absenteeism(workContext);
        }else{
            workContext.setState(new CurrTime10());
            workContext.work();
        }

    }


    private void absenteeism(WorkContext workContext){

        if(workContext.getPersonState() == 1){

            System.out.println("完蛋，今天要旷工了");

        }else{
            delay(workContext);
        }
    }

    private void delay(WorkContext workContext){

        if(workContext.getPersonState() == 2){
            System.out.println("哇！来不及吃饭了，马上要迟到了");
        }else{
            maybeDelay(workContext);
        }

    }

    private void maybeDelay(WorkContext workContext){
         if(workContext.getPersonState() == 3){
            System.out.println("抓紧抓紧，马上要迟到了");
        }else {
             working(workContext);
         }
    }

    private void working(WorkContext workContext){
        if(workContext.getPersonState() == 4){
            System.out.println("coding。。。。请勿打扰");
        }else{
            other();
        }
    }

    private void other(){
        System.out.println("未知状态，错误警告");
    }
}

